﻿<UserControl x:Class="Schedulr.Plugins.BackupConfiguration.BackupConfigurationPluginSettingsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:w="http://schemas.jelle.druyts.net/2010/xaml/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <w:EnumToBooleanConverter x:Key="enumConverter" />
    </UserControl.Resources>
    <StackPanel Orientation="Vertical">
        <TextBlock Text="Note that a new backup will not be created if nothing has changed since the last backup." Foreground="{DynamicResource UserMessageFontBrush}" TextWrapping="Wrap" Margin="0,0,0,5" />
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Content="Backup file" Margin="0,0,5,0" VerticalAlignment="Center" />
            <Grid Grid.Row="0" Grid.Column="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBox Grid.Column="0" Text="{Binding Path=BackupFileName, Mode=TwoWay}" />
                <Button Grid.Column="1" Content="..." x:Name="browseBackupFileNameButton" Click="browseBackupFileNameButton_Click" Margin="5,0,0,0" Style="{DynamicResource MediumButton}" />
            </Grid>

            <RadioButton Grid.Row="1" Grid.ColumnSpan="2" Margin="0,5,0,0" IsChecked="{Binding Path=Strategy, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Overwrite}"><Label Content="Overwrite existing backup file" /></RadioButton>
            <RadioButton Grid.Row="2" Grid.ColumnSpan="2" Margin="0,5,0,0" IsChecked="{Binding Path=Strategy, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=SuffixWithTimestamp}"><Label Content="Create a new backup file each time" /></RadioButton>

            <Grid Grid.Row="3" Grid.ColumnSpan="2" Margin="20,5,0,0">
                <Grid.Style>
                    <Style TargetType="Grid">
                        <Setter Property="IsEnabled" Value="False" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=Strategy}" Value="SuffixWithTimestamp">
                                <Setter Property="IsEnabled" Value="True" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Keep only the latest" Margin="0,0,0,0" VerticalAlignment="Center" />
                <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="5,0,0,0">
                    <TextBox Text="{Binding Path=NumberOfBackupsToKeep}" MinWidth="40" />
                    <TextBlock Text="backup files (or 0 to keep all files)" Margin="5,0,0,0" VerticalAlignment="Center" />
                </StackPanel>
            </Grid>
        </Grid>
    </StackPanel>
</UserControl>